package Lee_code;

import java.util.Arrays;

public class Lee_1365 {
    public int[] smallerNumbersThanCurrent(int[] nums) {
        int[] res = new int[nums.length];
        int[] temp = new int[nums.length];

        for (int i = 0; i < nums.length; i++) {
            temp[i] = nums[i];
        }

        Arrays.sort(temp);
        for (int i = 0; i < nums.length; i++) {
            res[i] = count(temp, nums[i]);
        }
        return res;
    }

    private int count(int[] temp, int num) {
        int i=0;
        while (temp[i] != num) {
            i++;
        }
        return i;
    }
}
